using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
    public class tbCTHoaDonBUS
    {
        public static void Insert(tbCTHoaDon cthd)
        {
            tbCTHoaDonDAL cthdDAL = new tbCTHoaDonDAL();
            cthdDAL.Insert(cthd);
        }
        public static void Update(tbCTHoaDon cthd)
        {
            tbCTHoaDonDAL cthdDAl = new tbCTHoaDonDAL();
            cthdDAl.Update(cthd);
        }
        public static void Delete(int iD)
        {
            tbCTHoaDonDAL cthdDAl = new tbCTHoaDonDAL();
            cthdDAl.Delete(iD);
        }
        public static tbCTHoaDonCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbCTHoaDonDAL cthdDAL = new tbCTHoaDonDAL();
            return cthdDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCTHoaDonCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTHoaDonDAL cthdDAL = new tbCTHoaDonDAL();
            return cthdDAL.Get(cri.Criter, 0, 0, tbCTHoaDonColumns.mahd.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbCTHoaDon GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbCTHoaDonColumns.mahd.ToString(), Condition.EQUAL, iD);
            tbCTHoaDonDAL cthdDAL = new tbCTHoaDonDAL();
            tbCTHoaDonCollection cthdCollection = cthdDAL.Get(cri.Criter, 0, 0, tbCTHoaDonColumns.mahd.ToString(), OrderDirection.ASC.ToString(), out total);
            if (cthdCollection.Count > 0)
                return cthdCollection[0];
            return null;
        }
    }
}
